package com.xb.springtest.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * knife4版本的swagger配置
 *
 * @author xiaosongyue
 * @date 2021/04/16 11:48:40
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class Knife4SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xb.springtest.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("SpringBoot测试项目")
                .description("项目描述，冲冲冲")
                .version("1.0.0")
                .contact(new Contact("xb","http://www.baidu.com","123@qq.com"))
                .license("Home")
                .licenseUrl("http://localhost/swagger-ui.html")
                .build();
    }
}